package com.itcast.jobs;

import com.itcast.constant.RedisConstant;
import org.springframework.beans.factory.annotation.Autowired;
import redis.clients.jedis.JedisPool;

import java.util.Set;

public class ClearImgJob {

    @Autowired
    private JedisPool jedisPool;
    public void clearImg(){
        //从redis中获取需要删除的图片name
        Set<String> stringSet = jedisPool.getResource().sdiff(RedisConstant.SETMEAL_PIC_RESOURCES, RedisConstant.SETMEAL_PIC_DB_RESOURCES);
        //遍历集合
        for (String name : stringSet) {
            //删除七牛云的图片
            //QiniuUtils.deleteFileFromQiniu(name);
            //删除redis的数据
            jedisPool.getResource().srem(RedisConstant.SETMEAL_PIC_RESOURCES,name);
        }
    }
}
